<!--样本统计-->
<!--根据数据库主键：条码（string）CRUD-->
<!--8->13-->
<template>
  <div class="div_main">
    <!--  表单-->
    <el-table
      :data="tableData"
      border
      style="width: 100%"
      :header-cell-style="{textAlign: 'center'}"
      :cell-style="{ textAlign: 'center' }"
    >

      <el-table-column
        prop="saId"
        label="id">
      </el-table-column>
      <el-table-column
        prop="saName"
        label="设置长度">
      </el-table-column>
      <el-table-column
        prop="saValue"
        label="长度">
      </el-table-column>

      <el-table-column label="操作" width="180">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            class="el-icon-edit"
            @click="handleEdit(scope.$index, scope.row)">
            修改
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 编辑窗口 -->
    <el-dialog
      title="编辑"
      :visible.sync="editFormVisible"
      width="25vw"
    >
      <el-form
        :model="editForm"
        ref="editForm"
      >
        <el-form-item
          label="阈值"
          label-width="80px"
        >
          <el-input
            v-model="editForm.saValue"
            autocomplete="off"
          ></el-input>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel()">取消</el-button>
        <el-button
          type="primary"
          v-on:click="sumbitEditRow()"
        >确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
var _index;
export default {
  name: "ybtjConfig",
  data() {
    return{
      tableData:[
      ],
      editFormVisible:false,
      //修改接收数组
      editForm:[
        {
          saId:'',
          saName:'',
          saValue: '',
        }
      ],

      rules: {},
      total: null,
      size: null,
    }
  },
  methods:{
    handleEdit(index, row) {
      this.editFormVisible = true;
      this.editForm = Object.assign({},row); //重置对象
      _index = index;
    },
    //保存数据
    sumbitEditRow() {
      var editData = _index;
      this.tableData[editData].saValue = this.editForm.saValue;
      this.$axios
        // .put("saupd", this.editForm) jpa接口
        .put("sample/saupd", this.editForm)
      this.editFormVisible = false;
    },
    cancel() {
      this.editFormVisible = false;
    },
  },
  created() {
    const _this = this;
    this.$axios
      // .get("saqueryall/1/5") jpa接口
      .get("sample/sampleAll")
      .then(function (resp) {
        //覆盖假数据
        _this.tableData = resp.data.data;
      });
  },
}
</script>

<style scoped>
  .div_main{}
</style>
